import { type } from 'os'
import { h,render } from 'vue'
import XtxMessage from './index.vue'
type ParamsType ={
  type:'success'|'error'|'warning',
  message:string
  duration?:number
}
// 创建盛放组件容器
const MessageContainer = document.createElement('div')
MessageContainer.className='Xtx-Message'
document.body.appendChild(MessageContainer)
export default function Message({type,message,duration=3000}:ParamsType){
  // 创建虚拟dom
  const vnode = h(XtxMessage,{type,message})
  // 挂载
  render(vnode,MessageContainer)
  setTimeout(()=>{
    render(null,MessageContainer)
  },duration)
}